home *** CD-ROM | disk | FTP | other *** search
/ NetObjects Fusion 7 / Fusion7.iso / NetObjects Fusion / data1.cab / Language_Resource_-_English / Components / TickerTape / TickerTapeComp.jar / TickerTapeComp / TickerTapeComp.class (.txt)
Encoding:
Java Class File  |  2000-10-30  |  7.5 KB  |  306 lines

  1. package TickerTapeComp;
  2.  
  3. import com.netobjects.nfc.api.CStringArray;
  4. import com.netobjects.nfc.api.ComponentApp;
  5. import com.netobjects.nfc.api.DAssetManager;
  6. import com.netobjects.nfc.api.DDrawJava;
  7. import com.netobjects.nfc.api.DLayout;
  8. import com.netobjects.nfc.api.DRect;
  9. import com.netobjects.nfc.api.IDInspector;
  10. import java.util.ResourceBundle;
  11.  
  12. public class TickerTapeComp extends ComponentApp {
  13.    static final long serialVersionUID = -3238717140016679597L;
  14.    int Speed;
  15.    int Frame;
  16.    int Background;
  17.    int LED;
  18.    int LEDType;
  19.    int LEDSize;
  20.    int numImages;
  21.    int MaxImages;
  22.    DAssetManager assetMan;
  23.    DDrawJava theJavaApplet;
  24.    String[] imageNames;
  25.    int[] imageURLs;
  26.    String[] linkTargets;
  27.  
  28.    void allocateImageArray(int n) {
  29.       this.imageNames = new String[n];
  30.       this.imageURLs = new int[n];
  31.       this.linkTargets = new String[n];
  32.  
  33.       for(int cnt = 0; cnt < n; ++cnt) {
  34.          this.imageURLs[cnt] = -1;
  35.          this.imageNames[cnt] = "";
  36.          this.linkTargets[cnt] = "";
  37.       }
  38.  
  39.    }
  40.  
  41.    public void onCopy() {
  42.       String[] imageNamesOld = this.imageNames;
  43.       int[] imageURLsOld = this.imageURLs;
  44.       this.allocateImageArray(this.MaxImages);
  45.  
  46.       for(int cnt = 0; cnt < this.numImages; ++cnt) {
  47.          this.imageNames[cnt] = new String(imageNamesOld[cnt]);
  48.          if (imageURLsOld[cnt] != 0 && imageURLsOld[cnt] != -1) {
  49.             this.imageURLs[cnt] = imageURLsOld[cnt];
  50.             this.assetMan.CopyAsset(imageURLsOld[cnt]);
  51.          }
  52.       }
  53.  
  54.    }
  55.  
  56.    public void onDrop(DLayout layout, DRect r, int fDrop) {
  57.       try {
  58.          if (fDrop != 1) {
  59.             if (this.LEDSize == 0) {
  60.                this.LEDSize = 2;
  61.             }
  62.  
  63.             return;
  64.          }
  65.  
  66.          this.numImages = 1;
  67.          this.Speed = 25;
  68.          this.Frame = 6;
  69.          this.Background = 0;
  70.          this.LED = 5;
  71.          this.LEDType = 0;
  72.          this.LEDSize = 2;
  73.          this.allocateImageArray(this.MaxImages);
  74.          this.theJavaApplet = new DDrawJava();
  75.          this.theJavaApplet.setImageFile(this.theJavaApplet.getCodeBase() + "TickerTape.jpg");
  76.          this.theJavaApplet.setStretch(2);
  77.          this.theJavaApplet.setAppletFileName(this.theJavaApplet.getCodeBase() + "TickerTape.class");
  78.          this.theJavaApplet.SetPositionRect(r.getLeft(), r.getTop(), r.getRight(), r.getBottom());
  79.          layout.AddObject(this.theJavaApplet);
  80.       } catch (Throwable var6) {
  81.       }
  82.  
  83.    }
  84.  
  85.    protected void onFinalize() {
  86.       for(int cnt = 0; cnt < this.numImages; ++cnt) {
  87.          if (this.imageURLs[cnt] != 0 && this.imageURLs[cnt] != -1) {
  88.             this.assetMan.RemoveAsset(this.imageURLs[cnt]);
  89.          }
  90.       }
  91.  
  92.    }
  93.  
  94.    public void onInspect(CStringArray Names, CStringArray Types) {
  95.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Number_of_Messages"));
  96.       Types.Set("Collection");
  97.  
  98.       for(int cnt = 0; cnt < this.numImages; ++cnt) {
  99.          Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Text_for_Message") + " " + Integer.toString(cnt + 1));
  100.          Types.Set("String");
  101.          Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("URL_for_Message") + " " + Integer.toString(cnt + 1));
  102.          Types.Set("Link");
  103.       }
  104.  
  105.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Speed"));
  106.       Types.Set("Collection");
  107.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Frame_Color"));
  108.       Types.Set("Set(" + ResourceBundle.getBundle("TickerTapeComp").getString("Color_List") + ")");
  109.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Background_Color"));
  110.       Types.Set("Set(" + ResourceBundle.getBundle("TickerTapeComp").getString("Color_List") + ")");
  111.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Color"));
  112.       Types.Set("Set(" + ResourceBundle.getBundle("TickerTapeComp").getString("Color_List") + ")");
  113.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Type"));
  114.       Types.Set("Collection");
  115.       Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Font_Size"));
  116.       Types.Set("Collection");
  117.    }
  118.  
  119.    public String onInstall(DAssetManager cam, String codeBase) {
  120.       this.MaxImages = 50;
  121.       this.assetMan = cam;
  122.       return ResourceBundle.getBundle("TickerTapeComp").getString("Component_Name");
  123.    }
  124.  
  125.    public void onPublish(DAssetManager asm, int context) {
  126.       if (this.linkTargets == null) {
  127.          this.linkTargets = new String[this.numImages];
  128.  
  129.          for(int i = 0; i < this.numImages; ++i) {
  130.             this.linkTargets[i] = "";
  131.          }
  132.       }
  133.  
  134.       this.theJavaApplet.AddParam("speed", "int", Integer.toString(this.Speed));
  135.       this.SetColor("framecolor", this.Frame);
  136.       this.SetColor("backcolor", this.Background);
  137.       this.SetColor("ledcolor", this.LED);
  138.       if (this.LEDSize < 3 && this.LEDType == 1) {
  139.          this.theJavaApplet.AddParam("ledtype", "int", "0");
  140.       } else {
  141.          this.theJavaApplet.AddParam("ledtype", "int", Integer.toString(this.LEDType));
  142.       }
  143.  
  144.       if (this.LEDSize < 1) {
  145.          this.LEDSize = 2;
  146.       }
  147.  
  148.       this.theJavaApplet.AddParam("LEDsize", "int", Integer.toString(this.LEDSize));
  149.  
  150.       for(int cnt = 0; cnt < this.numImages; ++cnt) {
  151.          this.theJavaApplet.AddParam("text" + Integer.toString(cnt + 1), "String", this.imageNames[cnt]);
  152.          String theURL;
  153.          if (this.imageURLs[cnt] != -1) {
  154.             theURL = this.assetMan.GetAssetRelativeLocation(this.imageURLs[cnt], context, 1);
  155.          } else {
  156.             theURL = "";
  157.          }
  158.  
  159.          this.theJavaApplet.AddParam("link" + Integer.toString(cnt + 1), "String", theURL);
  160.          this.theJavaApplet.AddParam("target" + Integer.toString(cnt + 1), "String", this.linkTargets[cnt]);
  161.       }
  162.  
  163.    }
  164.  
  165.    public void onUnInstall(DAssetManager cam) {
  166.    }
  167.  
  168.    public String PropertyListener(String Event, String Value, int Get, int propIndex, IDInspector insp) {
  169.       if (Get == 1) {
  170.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Number_of_Messages")) == 0) {
  171.             return Integer.toString(this.numImages);
  172.          }
  173.  
  174.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Speed")) == 0) {
  175.             return Integer.toString(this.Speed);
  176.          }
  177.  
  178.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Frame_Color")) == 0) {
  179.             return Integer.toString(this.Frame);
  180.          }
  181.  
  182.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Background_Color")) == 0) {
  183.             return Integer.toString(this.Background);
  184.          }
  185.  
  186.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Color")) == 0) {
  187.             return Integer.toString(this.LED);
  188.          }
  189.  
  190.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Type")) == 0) {
  191.             return Integer.toString(this.LEDType);
  192.          }
  193.  
  194.          if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Font_Size")) == 0) {
  195.             return Integer.toString(this.LEDSize);
  196.          }
  197.  
  198.          for(int cnt = 0; cnt < this.numImages; ++cnt) {
  199.             if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Text_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
  200.                return new String(this.imageNames[cnt]);
  201.             }
  202.  
  203.             if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("URL_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
  204.                return Integer.toString(this.imageURLs[cnt]);
  205.             }
  206.          }
  207.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Number_of_Messages")) == 0) {
  208.          int newNumImages = Integer.parseInt(Value, 10);
  209.          if (newNumImages < 1) {
  210.             return "";
  211.          }
  212.  
  213.          this.numImages = newNumImages;
  214.          if (this.numImages > this.MaxImages) {
  215.             this.numImages = this.MaxImages;
  216.          }
  217.  
  218.          for(int i = newNumImages; i < this.MaxImages; ++i) {
  219.             this.imageURLs[i] = -1;
  220.             this.imageNames[i] = "";
  221.          }
  222.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Speed")) == 0) {
  223.          this.Speed = Integer.parseInt(Value, 10);
  224.          if (this.Speed < 1) {
  225.             this.Speed = 1;
  226.          } else if (this.Speed > 50) {
  227.             this.Speed = 50;
  228.          }
  229.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Frame_Color")) == 0) {
  230.          this.Frame = Integer.parseInt(Value, 10);
  231.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Background_Color")) == 0) {
  232.          this.Background = Integer.parseInt(Value, 10);
  233.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Color")) == 0) {
  234.          this.LED = Integer.parseInt(Value, 10);
  235.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Type")) == 0) {
  236.          this.LEDType = Integer.parseInt(Value, 10);
  237.          if (this.LEDType < 0) {
  238.             this.LEDType = 0;
  239.          } else if (this.LEDType > 2) {
  240.             this.LEDType = 2;
  241.          }
  242.       } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Font_Size")) == 0) {
  243.          this.LEDSize = Integer.parseInt(Value, 10);
  244.          if (this.LEDSize < 1) {
  245.             this.LEDSize = 1;
  246.          } else if (this.LEDSize > 10) {
  247.             this.LEDSize = 10;
  248.          }
  249.       } else {
  250.          for(int cnt = 0; cnt < this.numImages; ++cnt) {
  251.             if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Text_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
  252.                this.imageNames[cnt] = Value;
  253.             }
  254.  
  255.             if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("URL_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
  256.                this.imageURLs[cnt] = Integer.parseInt(Value, 10);
  257.                if (this.assetMan.LinkHasFrames(this.imageURLs[cnt]) == 0) {
  258.                   this.linkTargets[cnt] = this.assetMan.GetTargetFromLink(this.imageURLs[cnt]);
  259.                } else {
  260.                   this.linkTargets[cnt] = "";
  261.                }
  262.  
  263.                if (this.imageURLs[cnt] != -1) {
  264.                   this.assetMan.GetAssetLocation(this.imageURLs[cnt], 0, 1);
  265.                } else {
  266.                   String var10 = "";
  267.                }
  268.             }
  269.          }
  270.       }
  271.  
  272.       return "";
  273.    }
  274.  
  275.    private void SetColor(String VarName, int SetVal) {
  276.       if (SetVal == 0) {
  277.          this.theJavaApplet.AddParam(VarName, "String", "black");
  278.       } else if (SetVal == 1) {
  279.          this.theJavaApplet.AddParam(VarName, "String", "blue");
  280.       } else if (SetVal == 2) {
  281.          this.theJavaApplet.AddParam(VarName, "String", "cyan");
  282.       } else if (SetVal == 3) {
  283.          this.theJavaApplet.AddParam(VarName, "String", "darkGray");
  284.       } else if (SetVal == 4) {
  285.          this.theJavaApplet.AddParam(VarName, "String", "gray");
  286.       } else if (SetVal == 5) {
  287.          this.theJavaApplet.AddParam(VarName, "String", "green");
  288.       } else if (SetVal == 6) {
  289.          this.theJavaApplet.AddParam(VarName, "String", "lightGray");
  290.       } else if (SetVal == 7) {
  291.          this.theJavaApplet.AddParam(VarName, "String", "magenta");
  292.       } else if (SetVal == 8) {
  293.          this.theJavaApplet.AddParam(VarName, "String", "orange");
  294.       } else if (SetVal == 9) {
  295.          this.theJavaApplet.AddParam(VarName, "String", "pink");
  296.       } else if (SetVal == 10) {
  297.          this.theJavaApplet.AddParam(VarName, "String", "red");
  298.       } else if (SetVal == 11) {
  299.          this.theJavaApplet.AddParam(VarName, "String", "white");
  300.       } else if (SetVal == 12) {
  301.          this.theJavaApplet.AddParam(VarName, "String", "yellow");
  302.       }
  303.  
  304.    }
  305. }
  306.